package com.allwees.bs.module.oms.dto;

import com.allwees.bs.core.model.order.wf.refund.ERefundAction;
import com.allwees.bs.module.oms.entity.OrderRefund;
import com.allwees.core.common.util.http.RequestContext;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.ResourceBundle;

@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
public class OrderRefundDto extends OrderRefund implements Serializable {

    /** 数量 **/
    private Integer quantity;

    /** 价格 **/
    private BigDecimal price;

    /** 金额 **/
    private BigDecimal amount;


    public String getRefundPhaseDesc() {
        ResourceBundle resourceBundle = RequestContext.getContext().getResourceBundle();
        if (this.latestAction == null) {
            return "";
        }
        if (  this.latestAction.name().equals(ERefundAction.USER_REQUEST_REFUND_ON_LIMIT.name()) || this.latestAction.name().equals(ERefundAction.RETAILER_CANCEL_SHIPPED_ON_LIMIT.name()) ) {
            return resourceBundle.getString("refundStatus.UN_SHIPPING_PHASE");
        } else {
            return resourceBundle.getString("refundStatus.AFTER_SHIPPING_PHASE");
        }

    }

    public String getRefundLauncher() {
        if (this.latestAction == null) {
            return "";
        }
        if (  !this.latestAction.name().equals(ERefundAction.RETAILER_CANCEL_SHIPPED_ON_LIMIT.name()) && !this.latestAction.name().equals(ERefundAction.PLATFORM_CANCEL_SHIPPED.name())
               && !this.latestAction.name().equals(ERefundAction.RETAILER_CANCEL_SHIPPED_AFTER_LIMIT.name()) ) {
            return "(C)";
        } else if (this.latestAction.name().equals(ERefundAction.RETAILER_CANCEL_SHIPPED_ON_LIMIT.name()) || (this.latestAction.name().equals(ERefundAction.RETAILER_CANCEL_SHIPPED_AFTER_LIMIT.name()))) {
            return "(B)";
        } else if ( this.latestAction.name().equals(ERefundAction.PLATFORM_CANCEL_SHIPPED.name()) ) {
            return "(A)";
        }
      return null;
    }

    public String getStatusDesc() {
        return status != null ? getEStatus().desc() : "";
    }
}
